package cn.wsalix.biz.entity;

import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import lombok.Data;
import lombok.EqualsAndHashCode;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import cn.anlaser.entity.ParentEntity;
import cn.wsalix.admin.entity.SysUser;

/**
 * @author jskyme
 * 会议/活动
 */
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "ACTIVITY")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@EntityListeners({ AuditingEntityListener.class })
@Data
@EqualsAndHashCode(callSuper = false)
public class Activity extends ParentEntity<Activity> {/**
	 * 
	 */
	private static final long serialVersionUID = -1827691876080838511L;

	private String title;// 标题
	private String subTitle;// 标题
	private String content;// 內容
	
	private String logo;
	private Date entryStartTime;//报名开始时间
	private Date entryEndTime;//报名开始结束
	private Date startTime;//活动开始时间
	private Date endTime;//活动开始时间
	private int entryFee;//报名费用

	private String status;// 內容
	private String remarks;
	
	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_PRINCIPAL_USER"), name = "USER_ID")
	private SysUser principal;//负责人
	
	@OneToMany(cascade = CascadeType.MERGE, fetch = FetchType.LAZY, mappedBy = "activity")
	private Set<Participate> participates;
	/*
	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_PARTICIPATE"), name = "PARTICIPATE_ID")
	private Participate participator;*/
/*	
	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(name = "MASTER_ID")
	private Activity master;*/
}
